package com.dahuyou.netty.es.test;

import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.io.IOException;

@SpringBootTest
public class AAA {

    @Resource
    private RestHighLevelClient restHighLevelClient;

    @Test
    public void createIndex() throws IOException {        /**
         * 创建索引 request  put test_index
         */
//        @Test
//        public void createIndex() throws IOException {
            // 1、创建索引请求
            CreateIndexRequest request = new CreateIndexRequest("test_index");
            // 2、执行请求
            CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);
            System.out.println("createIndexResponse = " + createIndexResponse);
//        }

    }
}
